<template>
	<view class="outpatientList">
		<u-navbar title="社区门诊店" :is-back="false" :border-bottom="false" title-color="#111" :background="navbarBG">
			<view class="page_navbar_warp" @click="goBack">
				<image src="../../static/images/outpatient/left.png" mode="" class="navLeft"></image>
			</view>
		</u-navbar>
		<view class="list">
			<view class="item" v-for="(item,index) in list" :key="index" @click="goDetail(item.id)">
				<view class="logo">
					<image :src="BASE_URL+item.images" mode=""></image>
				</view>
				<view class="content">
					<view class="title u-line-1">{{item.name}}</view>
					<view class="tel">{{item.phone}}</view>
					<view class="address">{{item.address}}</view>
				</view>
			</view>
		</view>
		
	</view>
</template>
<script>
	import {
		BASE_URL
	} from '@/env.js'
	export default {
		components: {},
		data() {
			return {
				navbarBG: {
					backgroundColor: '#F5E0C1',
				},
				BASE_URL:BASE_URL,
				page: 0,
				total: '',
				list: [],
			}
		},
		// 上拉加载
		onReachBottom(e) {
			console.log('上啦加载');
			this.getList();
		},
		onLoad(){
			this.getList();
		},
		methods: {
			getList() {
				if (this.total === this.list.length) {
					return;
				} else {
					this.page++;
					this.$https('outpatient.clinclist',{
						page: this.page,
					}).then(res => {
						if(res.code == 1){
							if(this.page == 1){uni.stopPullDownRefresh()}
							this.total = res.data.total;
							let arr = res.data.data;
							if (this.page === 1) this.list = [];
							this.list = this.list.concat(arr);
						}else{
							uni.stopPullDownRefresh()
						}
					});
				}
			},
			goBack(){
				uni.navigateBack({
					delta: 1,
					animationType: 'pop-out',
					animationDuration: 300
				});
			},
			goDetail(id){
				uni.setStorageSync('outpatientId',id)
				uni.navigateTo({
					url: '/pages/outpatient/outpatientDetail?id='+id
				})
			},
			
		},
	}
</script>
<style scoped lang="scss">
	.outpatientList {
		position: relative;
		width: 100%;
		min-height: 100vh;
		background: #fff;
		.page_navbar_warp {
			display: flex;
			align-items: center;
			flex: 1;
			padding: 0 28rpx;
			.navLeft{
				width: 15rpx;
				height: 28rpx;
			}
		}
		
		.list{
			.item{
				display: flex;
				padding: 28rpx;
				border-bottom: 1rpx solid #EEEEEE;
				.logo{
					width: 90rpx;
					height: 90rpx;
					margin-right: 20rpx;
					border-radius: 50%;
					overflow:hidden;
					uni-image{
						width: 90rpx;
						height: 90rpx;
						
					}
				}
				.content{
					width: 600rpx;
					.title{
						padding-right: 30rpx;
						height: 42rpx;
						font-size: 30rpx;
						line-height: 50rpx;
						color: #111111;
						background: url(../../static/images/outpatient/3.png)no-repeat right center;
						background-size: 10rpx 20rpx;
					}
					.tel{
						padding-left: 38rpx;
						font-size: 26rpx;
						color: #777777;
						background: url(../../static/images/outpatient/1.png)no-repeat left center;
						background-size: 28rpx 28rpx;
						margin: 17rpx 0 15rpx;
					}
					.address{
						width: 540rpx;
						padding-left: 38rpx;
						font-size: 24rpx;
						line-height: 36rpx;
						color: #777777;
						background: url(../../static/images/outpatient/2.png)no-repeat left top;
						background-size: 24rpx 32rpx;
						text-align: justify;
					}
				}
			}
		}
	}
</style>
